```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java调试艺术：10个高效排错技巧</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #434343 0%, #000000 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 6px;
            font-family: 'Courier New', Courier, monospace;
        }
        .tooltip-icon {
            cursor: pointer;
            color: #4f46e5;
        }
        .section-divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
        }
        .tip-card {
            border-left: 4px solid #4f46e5;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 0.75;
            margin-right: 1rem;
            color: #4f46e5;
            font-weight: bold;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 md:py-32 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-6xl font-bold mb-6 leading-tight">Java调试艺术</h1>
            <h2 class="text-xl md:text-2xl font-medium mb-8 text-gray-300">10个高效排错技巧提升开发效率</h2>
            <div class="max-w-3xl mx-auto">
                <p class="text-lg md:text-xl text-gray-300 leading-relaxed drop-cap">
                    在Java开发过程中，排错(Debugging)是不可避免的，而高效的排错方法可以大大缩短问题定位时间，提高开发效率。许多Java开发者习惯于打印日志(System.out.println)来调试代码，但这种方式不仅低效，而且不适用于复杂问题的排查。
                </p>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-5xl px-4 md:px-0 py-12 md:py-16">
        <!-- Debugger Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-indigo-600 text-white p-3 rounded-full mr-4">
                    <i class="fas fa-bug text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">1. 利用IntelliJ IDEA的Debugger(调试器)</h2>
            </div>
            <p class="text-lg text-gray-700 mb-8">
                调试器(Debugger)是Java开发排错的利器，远比打印日志更高效。以下是几个高效的调试技巧：
            </p>

            <div class="grid md:grid-cols-2 gap-6 mb-12">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-map-marker-alt text-indigo-500 mr-2"></i> 设置断点(Breakpoint)
                    </h3>
                    <p class="text-gray-700 mb-4">在代码行左侧单击可添加断点，程序运行到此处会暂停。</p>
                    <div class="bg-gray-100 p-3 rounded-md mb-3">
                        <p class="text-gray-800 font-mono text-sm">快捷键: <span class="font-bold">Ctrl + F8</span></p>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-football-ball text-indigo-500 mr-2"></i> Step Over(单步跳过)
                    </h3>
                    <p class="text-gray-700 mb-4">执行当前代码行但不会进入方法内部。</p>
                    <div class="bg-gray-100 p-3 rounded-md mb-3">
                        <p class="text-gray-800 font-mono text-sm">快捷键: <span class="font-bold">F8</span></p>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-door-open text-indigo-500 mr-2"></i> Step Into(单步进入)
                    </h3>
                    <p class="text-gray-700 mb-4">进入方法内部，适用于查看方法的具体实现逻辑。</p>
                    <div class="bg-gray-100 p-3 rounded-md mb-3">
                        <p class="text-gray-800 font-mono text-sm">快捷键: <span class="font-bold">F7</span></p>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-md p-6 card-hover">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-calculator text-indigo-500 mr-2"></i> Evaluate Expression(表达式求值)
                    </h3>
                    <p class="text-gray-700 mb-4">在断点处输入变量或表达式，直接计算其值，适用于复杂逻辑调试。</p>
                    <div class="bg-gray-100 p-3 rounded-md mb-3">
                        <p class="text-gray-800 font-mono text-sm">快捷键: <span class="font-bold">Alt + F8</span></p>
                    </div>
                </div>
            </div>

            <div class="bg-indigo-50 p-6 rounded-xl border border-indigo-100">
                <h3 class="text-xl font-semibold text-indigo-800 mb-4 flex items-center">
                    <i class="fas fa-lightbulb text-indigo-600 mr-2"></i> 专家建议
                </h3>
                <p class="text-gray-700">
                    结合条件断点(Conditional Breakpoint)可以更精确地定位问题。右键点击断点，设置触发条件，只有当条件满足时才会暂停执行。
                </p>
            </div>
        </section>

        <div class="section-divider my-12"></div>

        <!-- Stack Trace Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-red-600 text-white p-3 rounded-full mr-4">
                    <i class="fas fa-exclamation-triangle text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">2. 通过异常堆栈(Stack Trace)快速定位问题</h2>
            </div>
            <p class="text-lg text-gray-700 mb-8">
                当程序抛出异常时，异常堆栈信息是最直接的线索。
            </p>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div>
                    <h3 class="text-xl font-semibold mb-4 text-red-700">如何正确阅读异常堆栈</h3>
                    <ul class="space-y-4">
                        <li class="flex items-start">
                            <div class="bg-red-100 text-red-600 rounded-full p-1 mr-3 mt-1">
                                <i class="fas fa-info-circle text-xs"></i>
                            </div>
                            <span><strong>异常类型</strong>：例如 <code class="bg-red-100 text-red-800 px-1 rounded">NullPointerException</code>、<code class="bg-red-100 text-red-800 px-1 rounded">ArrayIndexOutOfBoundsException</code>，代表了具体的错误类型。</span>
                        </li>
                        <li class="flex items-start">
                            <div class="bg-red-100 text-red-600 rounded-full p-1 mr-3 mt-1">
                                <i class="fas fa-info-circle text-xs"></i>
                            </div>
                            <span><strong>异常信息</strong>：例如 <code class="bg-red-100 text-red-800 px-1 rounded">Attempt to invoke virtual method 'void X.method()' on a null object reference</code>，说明了问题的根本原因。</span>
                        </li>
                        <li class="flex items-start">
                            <div class="bg-red-100 text-red-600 rounded-full p-1 mr-3 mt-1">
                                <i class="fas fa-info-circle text-xs"></i>
                            </div>
                            <span><strong>堆栈调用路径</strong>：异常堆栈由多个 <code class="bg-red-100 text-red-800 px-1 rounded">at</code> 语句组成，通常第一个非 <code class="bg-red-100 text-red-800 px-1 rounded">java.</code> 开头的类就是出错的源头。</span>
                        </li>
                    </ul>
                </div>
                <div>
                    <h3 class="text-xl font-semibold mb-4">示例代码</h3>
                    <div class="code-block p-4 rounded-lg mb-4">
                        <pre><code class="text-white">Exception in thread "main" java.lang.NullPointerException
    at com.example.MyClass.processData(MyClass.java:25)
    at com.example.Main.main(Main.java:10)</code></pre>
                    </div>
                    <p class="text-gray-700">此处 <code class="bg-gray-200 px-1 rounded">MyClass.java:25</code> 可能是 <code class="bg-gray-200 px-1 rounded">processData</code> 方法中访问了 <code class="bg-gray-200 px-1 rounded">null</code> 变量。</p>
                </div>
            </div>

            <div class="tip-card bg-white rounded-xl shadow-sm p-6">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-arrow-right text-indigo-600 mr-2"></i> 在IDEA直接跳转异常行
                </h3>
                <p class="text-gray-700">双击异常堆栈中的方法名，IDEA会自动跳转到出错代码所在行。</p>
            </div>
        </section>

        <div class="section-divider my-12"></div>

        <!-- Logging Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-blue-600 text-white p-3 rounded-full mr-4">
                    <i class="fas fa-file-alt text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">3. 使用@Slf4j记录日志，替代System.out.println</h2>
            </div>
            <p class="text-lg text-gray-700 mb-8">
                打印日志是最常见的调试方式，但 <code class="bg-gray-200 px-1 rounded">System.out.println</code> 有很多缺点，如不可控、影响性能等。<br>
                推荐使用 <code class="bg-gray-200 px-1 rounded">Slf4j</code> 进行日志记录：
            </p>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div>
                    <div class="code-block p-4 rounded-lg mb-6">
                        <pre><code class="text-white">import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MyService {
    public void process() {
        log.info("Processing data...");
        log.debug("Debugging details: {}", someVariable);
        log.error("An error occurred", exception);
    }
}</code></pre>
                    </div>
                </div>
                <div>
                    <h3 class="text-xl font-semibold mb-4">日志级别说明：</h3>
                    <ul class="space-y-4">
                        <li class="flex items-start">
                            <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded-md text-sm font-medium mr-3">DEBUG</span>
                            <span>用于开发调试，生产环境通常关闭。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-green-100 text-green-800 px-2 py-1 rounded-md text-sm font-medium mr-3">INFO</span>
                            <span>记录关键信息，生产环境可用。</span>
                        </li>
                        <li class="flex items-start">
                            <span class="bg-red-100 text-red-800 px-2 py-1 rounded-md text-sm font-medium mr-3">ERROR</span>
                            <span>记录异常信息，便于错误追踪。</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-blue-50 p-6 rounded-xl border border-blue-100">
                <h3 class="text-xl font-semibold text-blue-800 mb-4 flex items-center">
                    <i class="fas fa-keyboard text-blue-600 mr-2"></i> 如何快速启用日志？
                </h3>
                <p class="text-gray-700">
                    快捷键: <code class="bg-blue-100 text-blue-800 px-2 py-1 rounded-md">Ctrl + Shift + A</code>，搜索 <code class="bg-blue-100 text-blue-800 px-2 py-1 rounded-md">Registry</code>，启用 <code class="bg-blue-100 text-blue-800 px-2 py-1 rounded-md">ide.console.debug</code>，可查看更多调试信息。
                </p>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-purple-600 text-white p-3 rounded-full mr-4">
                    <i class="fas fa-project-diagram text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">调试方法关系图</h2>
            </div>

            <div class="bg-white rounded-xl shadow-md p-6">
                <div class="mermaid">
                    graph TD
                    A[高效Java调试] --> B(调试器使用)
                    A --> C(日志分析)
                    A --> D(异常处理)
                    A --> E(工具辅助)
                    
                    B --> B1[断点设置]
                    B --> B2[单步调试]
                    B --> B3[表达式求值]
                    
                    C --> C1[SLF4J日志]
                    C --> C2[日志级别]
                    C --> C3[日志筛选]
                    
                    D --> D1[堆栈分析]
                    D --> D2[异常类型]
                    D --> D3[快速定位]
                    
                    E --> E1[代码覆盖率]
                    E --> E2[内存分析]
                    E --> E3[线程分析]
                    E --> E4[Docker环境]
                </div>
            </div>
        </section>

        <!-- Other Sections -->
        <div class="grid md:grid-cols-2 gap-8 mb-20">
            <!-- Assert Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-yellow-600 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-check-circle"></i>
                    </div>
                    <h3 class="text-2xl font-bold">4. 使用assert语句进行单元测试排错</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    <code class="bg-gray-200 px-1 rounded">assert</code> 语句可用于验证某个条件是否满足，不满足则抛出异常，有助于快速定位Bug。
                </p>
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre><code class="text-white">public void test() {
    int expected = 10;
    int actual = calculateValue();
    assert expected == actual : "计算值错误，期望值 " + expected + "，实际值 " + actual;
}</code></pre>
                </div>
                <div class="bg-yellow-50 p-4 rounded-lg border border-yellow-100">
                    <h4 class="font-semibold text-yellow-800 mb-2">assert适用于：</h4>
                    <ul class="list-disc pl-5 text-gray-700">
                        <li>复杂计算的中间验证点</li>
                        <li>关键业务逻辑的预期检查</li>
                    </ul>
                </div>
            </section>

            <!-- Coverage Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-green-600 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-chart-bar"></i>
                    </div>
                    <h3 class="text-2xl font-bold">5. 善用IDEA的Run with Coverage</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    运行JUnit测试时，使用 <code class="bg-gray-200 px-1 rounded">Run with Coverage</code>（快捷键: <code class="bg-gray-200 px-1 rounded">Ctrl + Shift + F10</code>），可以查看哪些代码被执行，哪些未被覆盖。
                </p>
                <div class="bg-green-50 p-4 rounded-lg border border-green-100">
                    <h4 class="font-semibold text-green-800 mb-2">适用于：</h4>
                    <ul class="list-disc pl-5 text-gray-700">
                        <li>检查Bug产生的边界情况</li>
                        <li>优化测试用例，增加覆盖率</li>
                    </ul>
                </div>
            </section>

            <!-- Thread Dump Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-red-600 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-spinner"></i>
                    </div>
                    <h3 class="text-2xl font-bold">6. 在多线程环境下使用Thread Dump</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    如果程序发生死锁或线程阻塞，如何排查？
                </p>
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre><code class="text-white">jstack -l &lt;PID&gt;</code></pre>
                </div>
                <p class="text-gray-700">
                    在IDEA <strong>Debug界面</strong> 中，<strong>点击Threads</strong>，可以查看当前线程状态，找出死锁线程。
                </p>
            </section>

            <!-- Grep Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-blue-600 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-search"></i>
                    </div>
                    <h3 class="text-2xl font-bold">7. 使用grep快速筛选日志信息</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    在日志文件过大时，如何快速定位关键错误信息？
                </p>
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre><code class="text-white">cat application.log | grep "ERROR"

# 结合tail -f实时监控日志
tail -f application.log | grep "WARN"</code></pre>
                </div>
                <div class="bg-blue-50 p-4 rounded-lg border border-blue-100">
                    <h4 class="font-semibold text-blue-800 mb-2">适用于：</h4>
                    <ul class="list-disc pl-5 text-gray-700">
                        <li>生产环境问题排查</li>
                        <li>远程服务器日志分析</li>
                    </ul>
                </div>
            </section>

            <!-- Memory Analysis Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-purple-600 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-memory"></i>
                    </div>
                    <h3 class="text-2xl font-bold">8. 使用jconsole或VisualVM进行内存分析</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    Java程序卡顿或内存泄漏，如何分析？
                </p>
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre><code class="text-white">jvisualvm</code></pre>
                </div>
                <div class="bg-purple-50 p-4 rounded-lg border border-purple-100">
                    <h4 class="font-semibold text-purple-800 mb-2">适用于：</h4>
                    <ul class="list-disc pl-5 text-gray-700">
                        <li>排查 <code class="bg-purple-100 text-purple-800 px-1 rounded">OutOfMemoryError</code></li>
                        <li>分析高内存占用问题</li>
                    </ul>
                </div>
            </section>

            <!-- Lombok Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-indigo-600 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-shield-alt"></i>
                    </div>
                    <h3 class="text-2xl font-bold">9. 通过Lombok避免常见空指针问题</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    常见Bug：
                </p>
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre><code class="text-white">public class User {
    private String name;
    public void printLength() {
        System.out.println(name.length());  // 可能导致NullPointerException
    }
}</code></pre>
                </div>
                <p class="text-gray-700 mb-4">
                    使用 <code class="bg-gray-200 px-1 rounded">@NonNull</code> 进行参数校验：
                </p>
                <div class="code-block p-4 rounded-lg">
                    <pre><code class="text-white">import lombok.NonNull;

public void process(@NonNull String input) {
    System.out.println(input.length());
}</code></pre>
                </div>
            </section>

            <!-- Docker Section -->
            <section class="bg-white rounded-xl shadow-md p-6 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-teal-600 text-white p-2 rounded-full mr-3">
                        <i class="fab fa-docker"></i>
                    </div>
                    <h3 class="text-2xl font-bold">10. 使用Docker进行环境隔离</h3>
                </div>
                <p class="text-gray-700 mb-4">
                    如果Bug只在某个特定环境出现，如何复现？
                </p>
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre><code class="text-white">docker run -it --rm openjdk:11 java -jar myapp.jar</code></pre>
                </div>
                <div class="bg-teal-50 p-4 rounded-lg border border-teal-100">
                    <h4 class="font-semibold text-teal-800 mb-2">适用于环境依赖导致的Bug，例如：</h4>
                    <ul class="list-disc pl-5 text-gray-700">
                        <li>Java版本不匹配</li>
                        <li>依赖库冲突</li>
                    </ul>
                </div>
            </section>
        </div>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-400 py-10">
        <div class="container mx-auto max-w-5xl px-4 md:px-0 text-center">
            <div class="flex flex-col items-center">
                <div class="text-2xl font-bold text-white mb-4">技术小馆</div>
                <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors duration-300">
                    <i class="fas fa-globe mr-2"></i>www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 添加微交互效果
        document.addEventListener('DOMContentLoaded', function() {
            // 卡片悬停效果
            const cards = document.querySelectorAll('.card-hover');
            cards.forEach(card => {
                card.addEventListener('mouseenter', function() {
                    this.style.transform = 'translateY(-5px)';
                });
                card.addEventListener('mouseleave', function() {
                    this.style.transform = '';
                });
            });
            
            // 平滑滚动
            document.querySelectorAll('a[href^="#"]').forEach(anchor => {
                anchor.addEventListener('click', function (e) {
                    e.preventDefault();
                    document.querySelector(this.getAttribute('href')).scrollIntoView({
                        behavior: 'smooth'
                    });
                });
            });
        });
    </script>
</body>
</html>
```